package br.com.j7.jdesk.persistence.repository.impl;

import java.util.List;

import br.com.j7.jdesk.library.exception.RepositoryException;
import br.com.j7.jdesk.persistence.entity.Pages;
import br.com.j7.jdesk.persistence.entity.UsersGroups;
import br.com.j7.jdesk.persistence.repository.PageRepository;

public class PageRepositoryImpl extends AbstractRepository<Pages> implements PageRepository{

	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.impl.AbstractRepository#list()
	 */
	@Override
	public List<Pages> list() throws RepositoryException {
		try {
			return listByNamedQuery(Pages.class, "pages");
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}

	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.impl.AbstractRepository#find(java.lang.Integer)
	 */
	@Override
	public Pages find(Integer id) throws RepositoryException {
		try {
			return getEntity(Pages.class, id);
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.PageRepository#findByCdPage(java.lang.String)
	 */
	@Override
	public Pages findByCdPage(String cdPage) throws RepositoryException {
		try {
			return getEntity(Pages.class, "pageByCdPage",cdPage);
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.PageRepository#listPageByUserGroup(br.com.j7.jdesk.persistence.entity.UsersGroups)
	 */
	@Override
	public List<Pages> listPageByUserGroup(UsersGroups userGroup) throws RepositoryException {
		try {
			return listByNamedQuery(Pages.class, "pageByUserGroup", userGroup);
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}

}
